package com.pureut.storage.controller;


import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.storage.dto.BarCodePrintingDto;
import com.pureut.storage.dto.PrintDto;
import com.pureut.storage.service.BarCodePrintingService;
import com.pureut.storage.vo.BarCodePrintVo;
import com.pureut.storage.vo.PrintVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 条码打印
 * @author: CM
 * @date: 2023/4/3  9:55
 */
@RestController
@RequestMapping("/pickingBarPrint")
public class BarCodePrintingController extends BaseController {

    @Resource
    private BarCodePrintingService barCodePrintingService;


    /**
     * 条码打印列表
     */
    @RequiresPermissions("warehouse:inside:barcodePrinting:list")
    @GetMapping("/list")
    public TableDataInfo getList(BarCodePrintVo barCodePrintVo) {
        startPage();
        //查询库存列表
        List<BarCodePrintingDto> list = barCodePrintingService.getList(barCodePrintVo);
        return getDataTable(list);
    }

    /**
     * 公共打印通过物料号码带出相关信息
     */
    @GetMapping("/getMaterialNumber")
    public AjaxResult getMaterialNumber(String materialNumber,String type) {
        //查询库存列表
        PrintDto printDto = barCodePrintingService.getMaterialNumber(materialNumber,type);
        return AjaxResult.success(printDto);
    }

    /**
     * 打印
     */
    @Log(title = "新增水刺分切制令单", businessType = BusinessType.INSERT)
        @PostMapping("/print")
    public AjaxResult addOrderCutScheduling(@RequestBody PrintVo printVo) throws Exception {
        return AjaxResult.success(barCodePrintingService.print(printVo));
    }


}
